package com.linran.webjsonrsp.websocket;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 服务端发送消息实体
 *
 * @author lin
 * @date 2020-08-28 10:28
 */
@Setter
@Getter
@NoArgsConstructor
public class ServerMessage {
    private String responseMessage;
    private LocalDateTime time;
    private String from;

    private String content;

    public ServerMessage(String content) {
        this.content = content;
    }

    public ServerMessage(LocalDateTime time, String from, String content) {
        this.time = time;
        this.from = from;
        this.content = content;
    }

    public String getResponseMessage() {
        return from+" "+time.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)+":"+content;
    }
}
